/******************************************************************************
 * (C) Copyright 
 * FILE NAME:    drv_a2d_cfg.h
 * DESCRIPTION:
 * 
 * DATE BEGUN:  
 * BY:          
 * PRODUCT NAME:
 * APPLICATION:
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

#ifndef _DRV_CLOCK_CFG_H_
#define _DRV_CLOCK_CFG_H_
#include "sys_config.h"
/*****************************************************************************
** Default Macro Definition
*****************************************************************************/


/*****************************************************************************
** Config Macro Definition
*****************************************************************************/
	/*****************************************************************************/
	/**
	* Function Name: SYS_CLOCK_SOURCE
	* Description:	 system bus clock is from which source
	*				 system bus clock is for uart bps/timer/...
	*				 RTI clock is from which source
	*				 rti is for taskxxms based on 1ms timing in runMode
	*
	* Param:   0: IRC_1MHZ
	*		   1: OSC_8MHZ
	*		   2: OSC_16MHZ
	*
	*
	*		   ...
	* Author:  
	******************************************************************************/

#define IRC_1MHZ        (0U)
#define OSC_8MHZ        (1U)
#define OSC_16MHZ       (2U)
	
#define SYS_CLOCK_SOURCE   OSC_16MHZ

#define RTI_CLOCK_SOURCE   IRC_1MHZ

/*****************************************************************************/
/**
* Function Name:  SYSTEM_BUS_CLOCK
* Description:    set system bus clock value
*
* Param:  UINT:     MHz 
*                   CLK_8MHZ
*                   CLK_16MHZ
*                   
*
*
*          
* Author:  
******************************************************************************/
#define CLK_8MHZ        (8U)
#define CLK_16MHZ      (16U) 


#define SYSTEM_BUS_CLOCK      CLK_16MHZ



/*****************************************************************************
** Default Macro Definition
*****************************************************************************/


/****************************************************************************/
/*****************************************************************************/
/**
* Function Name:  API_PERIOD_WAKEUP_FROM_SLEEP_MODE
* Description: Autonomous Periodical Interrupt, API wakeup system from low 
*             power mode. use fACLK(10kHz) as API clock.
*
* if CPMUAPICTL_APICLK=0: Period = 2*(APIR[15:0] + 1) / f_ACLK(10KMz)
* then APIR = Period * f_ACLK / 2 - 1.
*
* Param:   API_PERIOD_1MS
*          API_PERIOD_2MS
*          API_PERIOD_4MS
*          API_PERIOD_8MS
*          API_PERIOD_10MS
*          API_PERIOD_20MS
*          API_PERIOD_30MS
*          API_PERIOD_40MS
*          API_PERIOD_50MS
*          API_PERIOD_60MS
*          API_PERIOD_70MS
*          API_PERIOD_80MS
*          API_PERIOD_90MS
*          API_PERIOD_100MS
*          API_PERIOD_200MS
*          API_PERIOD_500MS
*          API_PERIOD_1S
*
*          
* Author:  
******************************************************************************/

#define API_PERIOD_1MS      ((UINT16)4)
#define API_PERIOD_2MS      ((UINT16)9)
#define API_PERIOD_4MS      ((UINT16)19)
#define API_PERIOD_8MS      ((UINT16)39)
#define API_PERIOD_10MS     ((UINT16)49)
#define API_PERIOD_20MS     ((UINT16)99)
#define API_PERIOD_30MS     ((UINT16)149)
#define API_PERIOD_40MS     ((UINT16)199)
#define API_PERIOD_50MS     ((UINT16)249)
#define API_PERIOD_60MS     ((UINT16)299)
#define API_PERIOD_70MS     ((UINT16)349)
#define API_PERIOD_80MS     ((UINT16)399)
#define API_PERIOD_90MS     ((UINT16)449)
#define API_PERIOD_100MS    ((UINT16)499)
#define API_PERIOD_200MS    ((UINT16)999)
#define API_PERIOD_500MS    ((UINT16)2499)	
#define API_PERIOD_1S       ((UINT16)4999)
  

/*****************************************************************************/
/**
* Function Name: RTI_PERIOD  
* Description:   Table10-11 in Page372 of dataSheet.
*             
*
* Param:   RTI_PERIOD_1MS
*          
*          
* Author:  
******************************************************************************/
#if (RTI_CLOCK_SOURCE == OSC_8MHZ) 

    #define RTI_PERIOD_1MS      (0b00010011) /* 1*10^3*1us=1ms */

#elif (RTI_CLOCK_SOURCE == OSC_16MHZ) 

    #define RTI_PERIOD_1MS      (0b00010111) /* 1*10^3*1us=1ms */

#elif (RTI_CLOCK_SOURCE == IRC_1MHZ) 

    #define RTI_PERIOD_1MS      (0b00000000) /* 1*10^3*1us=1ms */

#else
    #error "MAC RTI_CLOCK_SOURCE is NOT defined !"    /* system clock Defines not found! */   
#endif 
#endif	//_DRV_A2D_CFG_H_

/*****************************************************************************
** End File
*****************************************************************************/

